package com.offcn.bigdata.dataset

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.api.scala._

/**
 * @Auther: BigData-LGW
 * @ClassName: FlinkScalaDataSetWordCount
 * @Date: 2020/12/15 20:04
 * @功能描述: $FunctionDescription
 * @Version:1.0
 */
object FlinkScalaDataSetWordCount {
    def main(args: Array[String]): Unit = {
        val env = ExecutionEnvironment.getExecutionEnvironment
        val lines = env.fromElements(
            "love is blind",
            "where shall i go to kill some time",
            "tale is cheap, show me the code"
        )
        val ret = lines.flatMap(line => line.split("\\s+"))
            .map(word => (word,1))
            .groupBy(0)
            .sum(1)
        ret.print()
    }
}
